<template>
  <div class="hello" style="background: #ccc;">
    <h1>{{ msg }}</h1>
    <button @click="handleChildClick">我是子组件的按钮</button>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
  name: 'HelloWorld',
  props: {
    msg: String
  },
  setup(props, context) {
    const handleChildClick = () => {
      console.log('handleChildClick')
      context.emit('toParent', '我是子组件传递给父组件的信息')
    }
    return {
      handleChildClick
    }
  }
})
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
